﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Xemhocsinh : System.Web.UI.Page
{
    BUS_Children objT = new BUS_Children();
    protected void Page_Load(object sender, EventArgs e)
    {

        string strcid = "", strpid = "";
        Page.Title = "Xem Thông tin Học Sinh";
        if (!IsPostBack)
        {
            if (Session["AdminLogin"] != null)
            {
                strcid = Request.QueryString.Get("cid");
                strpid = Request.QueryString.Get("id");
                if (strcid == null || strpid == null)
                {
                    Response.Redirect("Hocsinh.aspx");
                }
                else
                {
                    LoadData(Convert.ToInt16(Request.QueryString.Get("cid")), Convert.ToInt16(Request.QueryString.Get("id")));
                }
            }
            else Response.Redirect("Dangnhap.aspx");
        }
    }
    public void LoadData(int cgid, int pid)
    {
        try
        {
            DateTime ngay;
            int status;
            var dataT = objT.Children_getAllByPid(pid);
            linkxemgv.NavigateUrl = "Xemhocsinh.aspx?cid=" + cgid + "&id=" + pid;
            linksuagv.NavigateUrl = "Suahocsinh.aspx?cid=" + cgid + "&id=" + pid;
            linkthemgv.NavigateUrl = "Themhocsinh.aspx";
            linktimgv.NavigateUrl = "Timhocsinh.aspx";

            lienKet.Text = "Học Sinh";
            magv.Text = dataT.Rows[0]["Childrenid"].ToString();
            tengv.Text = dataT.Rows[0]["Fullname"].ToString();
            gt.Text = dataT.Rows[0]["Gentle"].ToString();
            //ngaysinh
            ngay = Convert.ToDateTime(dataT.Rows[0]["Birthday"].ToString());
            ns.Text = ngay.ToString("dd/MM/yyyy");
            dc.Text = dataT.Rows[0]["Address"].ToString();
            sdt.Text = dataT.Rows[0]["Phone"].ToString();
            hinhanhdaidien.ImageUrl = "~/Uploads/Children/" + dataT.Rows[0]["Photo"].ToString();
            status = int.Parse(dataT.Rows[0]["Status"].ToString());
            if (status == 1) trangthai.Text = "Mở"; else trangthai.Text = "Đóng";
        }
        catch
        {
        }

    }
}